< previous page page_505 next page >

Page 505
1. Start a new Standard EXE project.
2. Add a module to the project.
3. Add the code from Chapter 21 necessary to access INI files.
4. Add the code for the sndPlaySound API call from Chapter 20.
5. Draw a Timer control on the form, tmrMain, and set the Interval property to 900.
6. Make Sub Main the Startup object for the project.
7. You can also begin creating your INI file, using the sample in the preceding section as a model.
Setting Up the Communications Control
mscomm.gif The Microsoft Communications (MS Comm) Control allows your Visual Basic programs to transmit and receive data across a serial port or modem (also known as a COM port), much like a terminal emulation application. Before you can use the control in a program, you must add it to the Toolbox. To do so, right-click in an empty area of the Toolbox and select Components from the menu. From the Components dialog box, place a check in the box next to Microsoft Comm Control 6.0 and click OK. The control should then appear in your Toolbox.
Next, draw an instance of the control on your form. Note that it always appears as an icon no matter how large you attempt to draw it.
To set up the MS Comm Control for use with your modem, you need to set these properties:
CommPort. An integer that specifies the COM port to which your modem is attachedfor example, 2 for COM2.
Settings. A string that specifies the baud rate and parity settings.
These two properties can be set at design time or at the beginning of your program in the Load event or Sub Main procedure. If you have a modem on COM3, for example, the statements read as follow:
Form1.MSComm1.CommPort = 3
Form1.MScomm1.Settings = "9600,N,8,1"
Even if you set the CommPort and Settings properties at designtime, you still must perform several activities at program startup, namely initializing the communications control and sending the modem a command to turn on Caller ID display. The complete Sub Main procedure from the sample application is shown in Listing 23.1.
Listing 23.1 CALLID.ZIPInitialization Routine for the Caller ID Program
Sub Main()
    Dim nComPort As Integer
    Dim sInit As String
    Dim sTemp As String
    Dim bStop As Boolean
continues

 
< previous page page_505 next page >